Page({
    data: {
      title: '',
      content: '',
    },
    
    onChangeTitle: function(ev) {
        this.data.title = ev.detail
    },
    
    onChangeContent: function(ev) {
      this.data.content = ev.detail
    },

    onSave: function() {
        var self = this

        if (!self.data.title) {
            return wx.showToast({
                title: '请输入标题',
                icon: 'error',
            })
        }

        if (!self.data.content) {
          return wx.showToast({
              title: '请输入内容',
              icon: 'error',
          })
       }

        wx.showToast({
            title: '发布成功',
            icon: 'success',
            duration: 2000,
            success: () => {
                wx.switchTab({
                  url: '/pages/forum/index'
                })
            }
        })
    }
})